package com.hzw.service;

import com.hzw.api.IReserveService;
import com.hzw.common.DateUtils;
import com.hzw.dao.ReserveDao;
import com.hzw.entity.Reserve;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class ReserveService implements IReserveService {

    @Autowired
    ReserveDao reserveDao;


    @Override
    public List<Reserve> select(Reserve reserve) {
        return reserveDao.select(reserve);
    }

    @Override
    public void updateAdd(Reserve reserve) {
        reserve.setCreateTime(DateUtils.getNowTime());
        reserve.setStatus(1);
        reserveDao.updateById(reserve);
    }

    @Override
    public void updateDel(Reserve reserve) {
        List<Reserve> selectRes = reserveDao.select(reserve);
        for (Reserve s : selectRes) {
            s.setPhone(" ");
            s.setRealName(" ");
            s.setUserId(" ");
            s.setCreateTime(" ");
            s.setStatus(0);
            reserveDao.updateById(s);
        }
    }

    @Override
    public int insert(Reserve reserve) {
        reserve.setId(UUID.randomUUID().toString().replace("-", ""));
        reserve.setStatus(0);
        return reserveDao.insert(reserve);
    }

    @Override
    public void delById(Reserve reserve) {
        reserveDao.delById(reserve);
    }
}
